#!/bin/bash
#leao:Wed Aug 21 04:05:52 PM CST 2024
#!/bin/bash  
  
path=$1  
  
if [ -e "$path" ]; then  
    echo "文件存在，是否删除并重建 y/Y;退出n/N"  
    read val  
    if [[ "$val" == [yY] ]]; then  
        > "$path"  # 重定向空内容到文件，相当于清空文件  
        echo "重建成功（实际上是清空文件）"  
    elif [[ "$val" == [nN] ]]; then  
        exit  
    else  
        echo "输入无效，自动退出"  
        exit  
    fi  
else  
    echo "文件不存在，是否新建 y/Y;退出n/N"  
    read val  
    if [[ "$val" == [yY] ]]; then  
        touch "$path"  
        echo "新建成功"  
    elif [[ "$val" == [nN] ]]; then  
        exit  
    else  
        echo "输入无效，自动退出"  
        exit  
    fi  
fi